﻿@model List<BDShop.Entities.Category>
@using BDShop.Business.Cache
@using BDShop.Entities
@using BDShop.Utilities.Managers

<div class="box">
    <div class="box-heading">Danh mục</div>
    <div class="box-content box-category">
        <ul id="cat_accordion">
            @{
                Category currentCat = CategoryCache.GetByID(ViewBag.CatID);
                string className;
                string url;
            }

            @foreach (var category in Model)
                {
                    List<Category> lstChildCategory = CategoryCache.GetParent(category.ID);
                    url = UrlManager.ProductOfCatUrl(category.ID, category.Name);
                    className = "";

                    if (currentCat.ID == category.ID || currentCat.ParentID == category.ID)
                     {
                         className = "active";
                     }
                   
                     <li class="custom_id20"><a class="@className" href="@url">@category.Name</a>
                   

                    @if (lstChildCategory.Count > 0)
                    {
                        <span class="down"></span>
                        <ul>
                            @foreach (var childCat in lstChildCategory)
                            {
                                url = UrlManager.ProductOfCatUrl(childCat.ID, childCat.Name);
                                <li class="custom_id26"><a class="" href="@url">@childCat.Name</a></li>
                            }
                        </ul>
                    }

                    </li>
                }
            
        </ul>
    </div>
</div>

